package logic

import (
	"beike/houserpc/houserpc"
	"context"

	"beike/api/internal/svc"
	"beike/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ResUpdateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewResUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResUpdateLogic {
	return &ResUpdateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ResUpdateLogic) ResUpdate(req *types.ResUpdateRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	resId, err := l.svcCtx.HouseRpc.ResUpdate(l.ctx, &houserpc.ResUpdateRequest{
		ResId: req.ResId,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    0,
		}, nil
	}

	return &types.Response{
		Message: "修改成功",
		Data:    resId,
		Code:    200,
	}, nil
}
